<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../js/vue.js"></script>
    <script src="../js/jquery.min.js"></script>
</head>
<body>
    <script>

        console.log("---------补全字符串---------")
        // es6引入了字符串补全长度的功能
        //padStart()用于头部0补全        padEnd()用于尾部补全
        //第一个参数是字符串补全生效的最大长度
        //第二个参数是用来补全的字符串
        
        let str1 = 'x'.padStart(5,'ab');
        console.log(str1);//ababx

        let str2 = 'x'.padStart(4,'ab');
        console.log(str2);//abax

        let str3 = 'x'.padEnd(5,'ab');
        console.log(str3);//xabab

        let str4 = 'x'.padEnd(4,'ab');
        console.log(str4);//xaba



        console.log("---------消除空格-----------");
        //trimStart()消除字符串的头部的空格
        //trimEnd()消除尾部的空格
        const s = ' welcome ';

        console.log(s.trim());
        console.log(s.trimStart());//'welcome '
        console.log(s.trimEnd());//' welcome'


        console.log("---------返回指定位置的字符------------");
        const str = 'hello';
        console.log(str.at(1));//e
        console.log(str.at(-1));//o



    </script>
    
</body>
</html>